#include<vector>

using namespace std;

class Solution {
public:
    int minSubArrayLen(int target, vector<int>& nums) {
        int left = 0;
        int right = 0;
        int sum = 0;
        int len = INT_MAX;
        while (right < nums.size())
        {
            if (sum < target)
            {
                sum += nums[right];
                if (sum < target)
                    right++;
                continue;
            }
            len = len > (right - left + 1) ? (right - left + 1) : len;
            sum -= nums[left];
            left++;
            if (sum < target)
                right++;
        }
        if (len == INT_MAX)
            return 0;
        return len;
    }
};

int main()
{
    Solution s;
    vector<int> v{ 2,3,1,2,4,3 };
    s.minSubArrayLen(7, v);
    return 0;
}